<template>
  <div class="cardWraper">
    <div class="top">
      <p v-for="(color, index) of cartColor1" :key="index" :style="{ backgroundColor: color }"
        @click="changeColor(index)"></p>
    </div>
    <div class="card" :style="{ backgroundColor: cartColor[cardBackGround] }">
      <textarea rows="10" placeholder="请输入..."></textarea>
      <input type="text" placeholder="作者">
    </div>
    <div class="label">
      <p class="labelTitle">选择标签</p>
      <div class="labelMain">
        <p v-for="(label, index) of labels" :key="index" class="labelLi" :class="{ action: index === labelIndex }"
          @click="labelSelect(index, label)">{{ label }}
        </p>
      </div>
    </div>
    <div class="mzsm">
      <p>免责声明</p>
      <p>1. 这是一份免责声明</p>
      <p>2. 这是一份免责声明</p>
      <p>3. 这是一份免责声明</p>
      <p>4. 这是一份免责声明</p>
      <p>5. 这是一份免责声明</p>
      <p>6. 这是一份免责声明</p>
      <p>7. 这是一份免责声明</p>
      <p>8. 这是一份免责声明</p>
    </div>
  </div>
  <div class="btn">
    <el-button class="discardBtn" round>丢弃</el-button>
    <el-button class="submitBtn" type="info" round>提交</el-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { storeToRefs } from 'pinia';

import { cartColor, cartColor1, lable } from '../assets/data/wall';
import { useMainStore } from '../store/index'

// store
const mainStore = useMainStore()
const { index } = storeToRefs(mainStore)

// 卡片背景
let cardBackGround = ref<number>(0)
// 修改卡片背景
const changeColor = (index: number): void => {
  cardBackGround.value = index
}
// 标签
const labels = lable[index.value]
// 标签选中状态
let labelIndex = ref<number>(0)
const labelSelect = (newIndex: number, label: String): void => {
  labelIndex.value = newIndex
}

</script>

<style lang="scss" scoped>
.cardWraper {
  width: 100%;
  height: 530px;
  position: relative;
  overflow-y: auto;
  position: relative;

  &::-webkit-scrollbar {
    width: 4px;
    height: 2px;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background-color: rgba(0, 0, 0, .5);
  }

  &::-webkit-scrollbar-track {
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0);
  }

  .top {
    padding: 10px 0 15px 15px;
    display: flex;

    p {
      width: 24px;
      height: 24px;
      margin-right: 10px;
      cursor: pointer;
      box-sizing: border-box;

      &:hover {
        border: 1px solid orange;
      }
    }
  }

  .card {
    width: 100%;
    height: 200px;

    &>textarea {
      width: 100%;
      resize: none;
      box-sizing: border-box;
      padding: 10px;
      background: none;
      border: none;
    }

    &>input {
      width: 98%;
      box-sizing: border-box;
      height: 30px;
      padding: 5px;
      background: none;
      border: 1px solid white;
      margin-left: 3px;
      font-size: 12px;
      padding-left: 10px;
    }
  }

  .label {
    width: 100%;
    // height: 160px;
    box-sizing: border-box;
    padding: 20px 0 5px 20px;

    .labelTitle {
      font-size: 16px;
      color: black;
      font-weight: 600;
    }

    .labelMain {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      margin-top: 10px;

      .labelLi {
        margin-right: 10px;
        margin-bottom: 10px;
        font-size: 12px;
        cursor: pointer;
        box-sizing: border-box;
        padding: 5px;
        border-radius: 20px;
        border: 2px solid orange;
        color: rgb(91, 91, 91);
      }

      .action {
        background-color: rgb(222, 211, 191);
        font-weight: 800;
        color: black;
        transition: .3s;
      }
    }
  }

  .mzsm {
    padding: 10px 0 20px 20px;

    &>p:first-child {
      font-size: 16px;
      font-weight: 600;
      padding-bottom: 10px;
    }

    &>p:not(:first-child) {
      font-size: 12px;
      color: rgb(115, 115, 115);
    }
  }

}

.btn {
  width: 300px;
  height: 60px;
  box-sizing: border-box;
  background-color: white;
  padding: 10px 0 10px 20px;
  position: fixed;
  right: 0;
  bottom: 0;
  border-top: 1px solid orange;

  .discardBtn {
    width: 100px;
    height: 40px;
  }

  .submitBtn {
    width: 150px;
    height: 40px;
  }
}
</style>